﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prism.Core.Net.Tcp
{
    [Serializable]
    public class DataTransportSpeedTracker
    {
        public DataTransportSpeedTracker()
        {
            this.NowLength = 0;
            this.PreLength = 0;
            this.TotalLength = 0;
            this.Timer = new System.Timers.Timer(1000d);
            this.Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
        }

        void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            this.OnTick();
        }

        public void Start()
        {
            this.Timer.Start();
        }


        public event EventHandler Tick;
        protected void OnTick()
        {
            if (this.Tick != null) { this.Tick(this, new EventArgs()); }
        }

        public int NowLength { get; set; }
        public int PreLength { get; set; }
        public int TotalLength { get; set; }

        private System.Timers.Timer Timer;
    }
}
